<style lang="less">
    @import '../../styles/common.less';
    @import '../tables/components/table.less';
</style>

<template>
    <div>
    	<Row >
            <Card>
                <p slot="title" style="height: 32px;">
                	<Col span="4">测评车辆：<span>{{result.teamName}}</span></Col>
	                <Col span="4">最终成绩：<span style="color: red;">{{result.teamTotalScore}}分</span></Col>   
            	    <span class="margin-left-10">选择线路</span>
                    <Select v-model="selected" style="width:200px" @on-change='selectChange'>
				        <Option v-for="item in roadList" v-bind:value="item.stadiumId" :key="item.stadiumName ">{{ item.stadiumName }}</Option>
				    </Select>               
           		 </p>
                <Row >
                	<Col span="8">{{result.stadiumName}}<span class="margin-left-10">{{result.time}}</span></Col>
	                <Col span="16">
	                	<Row type="flex" justify="end" class="code-row-bg" style="width: 100%;">
	                		 <Col span="4">路段得分：<span style="color: red;">{{result.roadScore}}分</span></Col>
	                		 <Col span="4">场景得分：<span style="color: red;">{{result.scenesScore}}分</span></Col>   
	                		 <Col span="4">时间得分：<span style="color: red;">{{result.timeScore}}分</span></Col>  
	                		 <Col span="4">总分数：<span style="color: red;">{{result.totalScore}}分</span></Col>    
	                	</Row>
	                	
	                </Col>  
	                  
	               
                </Row>
            </Card>
        </Row>
        <Row class="margin-top-10">
            <Col span="24">
                <Card>
                    <Row :gutter="10">
                        <Col span="24">
                            <div>
                                <can-edit-table 
                                    refs="table4" 
                                    v-model="tableList" 
                                    :columns-list="editInlineAndCellColumn"
                                    @on-link='onlink'
                                ></can-edit-table>
                                
                            </div>
                            
                        </Col>
					    
                    </Row>
                    <div style="margin-top: 10px;overflow: hidden">
				        <div style="float: left;">
				            <Page :total="total" @on-change="PageNo" :page-size="pageSize" show-elevator ></Page>
				        </div>
				    </div>
                </Card>
            </Col>
        </Row>
    </div>  
</template>

<script>
import 'jquery';
import tableData from './achievement_detail_data.js';
import canEditTable from '../components/canEditTable.vue';
import {adminId,accessToken,replaceTime,replaceHourTime} from '../components/date.js';
import {baseurl} from '../../libs/util.js';

export default {
    name: 'achievement_detail',
    components: {
        canEditTable
    },
    data () {
        return {
        	selected:1,
        	result:[],
            editInlineAndCellColumn: [],
            tableList: [],
            modal1: false,
	        total: 1,
	        pageSize: 10,
	        roadList:[
	        {
	        	stadiumId:1,
	        	stadiumName:'城乡赛场'
	        	
	        },
	        {
	        	stadiumId:2,
	        	stadiumName:'高速赛场'
	        }
//	        {
//	        	stadiumId:3,
//	        	stadiumName:'城郊赛场'
//	        }
	        ],
	        teamId:'',
        };
    },
    mounted:function(){     	
		this.team();		
	},
    methods: {
    	team : function(){
    		var teamId = this.$route.query.teamId;
    		var _self = this;     		
                $.ajax({
                    type: "get",
                    url: baseurl+'users/' + adminId + "/teams/" + teamId+ "/stadiumResult?stadiumId="+this.selected+"&time="+(new Date().getTime()),
                    async: false,                   
                    dataType: 'json',
                    contentType: "application/json; charset=utf-8",
                    beforeSend: function (request) {
                        request.setRequestHeader("accessToken", accessToken);
                    },
                    success: function (data) {
                    	var obj = data.result;
						_self.result = obj;
						if(_self.result.scenesResultList!=null){
							_self.tableList = _self.result.scenesResultList;
						}else{
							_self.tableList=[];
						}
						if(obj.startTime!=null&&obj.endTime){
							_self.result.time = replaceTime((obj.startTime) / 1000) + "~" + replaceHourTime(obj.endTime / 1000);
						}
						
			            _self.total = data.totalNum;
                    }
        		});
		},
        getData () {
            this.editInlineAndCellColumn = tableData.editInlineAndCellColumn;
        },
        //分页对应的页数
        PageNo (e) {
            console.log(e);
            this.team(e);
        },
                
        selectChange(){ 
		    this.team();
        	
        },
         onlink(data){  
         	let query ={scenesResultId : data.scenesResultId}        	
        	this.$router.push({
      		name:'achievement_edit',
	  		query: query
      		});  
        }
    },
     created () {
        this.getData();      
    },
    activated () {
        this.team();
    }

};
</script>


